package com.yuwubao.uav.tool.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yuwubao.framework.bean.JsonResult;
import com.yuwubao.framework.bean.PageData;
import com.yuwubao.framework.loginFilter.CurrentUserConstants;
import com.yuwubao.framework.loginFilter.LoginRequired;
import com.yuwubao.uav.tool.service.FrontService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.Min;
import javax.validation.constraints.Pattern;
import java.io.File;
import java.util.Date;

/**
 * 官网页面展示
 */
@RestController
@RequestMapping("/front")
public class FrontInfoController {

    private static final Logger logger = LogManager.getLogger(FrontInfoController.class);

    @Resource
    private FrontService frontService;

    @GetMapping("/getLearningMaterials")
    @ApiOperation(value = "获取学习资料详情")
    public JsonResult getLearningMaterials(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getLearningMaterials(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getEvaluation")
    @ApiOperation(value = "获取智库评价详情")
    public JsonResult getEvaluation(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getEvaluation(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getFileInfo")
    @ApiOperation(value = "获取文件详情")
    public JsonResult getFileInfo(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getFileInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getViewpointInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getViewpointInfo(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getViewpointInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getTtResultInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getTtResultInfo(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getTtResultInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getThinkTankInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getThinkTankInfo(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getThinkTankInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getSpecialInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getSpecialInfo(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getSpecialInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getProfessorInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getProfessorInfo(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getProfessorInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getPaternerInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getPaternerInfo(
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);

            result.setResult(frontService.getPaternerInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getMediaInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getMediaInfo(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getMediaInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getHotNewsInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getHotNewsInfo(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getHotNewsInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getForumInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getForumInfo(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getForumInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getDecisionInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getDecisionInfo(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getDecisionInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getDecisionCommentInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getDecisionCommentInfo(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getDecisionCommentInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getCourseInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getCourseInfo(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getCourseInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getAdviceInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getAdviceInfo(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getAdviceInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getAdverInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getAdverInfo(
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);

            result.setResult(frontService.getAdverInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getAllianceActivityInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getAllianceActivityInfo(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getAllianceActivityInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getFocusNewsInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getFocusNewsInfo(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getFocusNewsInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getOrgDynamicInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getOrgDynamicInfo(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getOrgDynamicInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getOrgProjectInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getOrgProjectInfo(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getOrgProjectInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getOrgResultInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getOrgResultInfo(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getOrgResultInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getOrgPublishInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getOrgPublishInfo(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getOrgPublishInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getOrgJgInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getOrgJgInfo(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getOrgJgInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getOrgLeaderInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getOrgLeaderInfo(
            HttpServletRequest request,
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            result.setResult(frontService.getOrgLeaderInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }
    @GetMapping("/getUserPublishInfo")
    @ApiOperation(value = "获取详情")
    public JsonResult getUserPublishInfo(
            @ApiParam(value = "是否是收藏标示 0：非收藏操作，1：收藏操作") @RequestParam(value = "flag",required = false,defaultValue = "0") String flag,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("flag", flag);

            result.setResult(frontService.getUserPublishInfo(pageData));
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }

    @PostMapping("/jb")
    @ApiOperation(value = "举报")
    public JsonResult jb(
            @ApiParam(value = "类型 0：评论举报，1：发布举报") @RequestParam(value = "type",required = false,defaultValue = "0") String type,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            pageData.put("type", type);

            result.setResult("感谢您的举报，我们会尽快处理！");
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }

    @PostMapping("/lh")
    @ApiOperation(value = "拉黑")
    public JsonResult lh(
            HttpServletRequest request,
            @ApiParam(value = "ID", required = true) @NotEmpty @RequestParam("id") String id
    ) {
        JsonResult result = new JsonResult();
        try {
            PageData pageData = new PageData();
            pageData.put("id", id);
            Object userIdObj = request.getAttribute(CurrentUserConstants.CURRENT_USER);
            if (userIdObj != null) {
                pageData.put("userId",userIdObj.toString());
            }

            frontService.lh(pageData);
            result.setSuccessful();

        } catch (Exception e) {
            logger.error("", e);
            result.setFailure(e.getMessage());
        }

        return result;
    }

}
